package org.oexam.ostudy.facade.struct;

import java.sql.SQLException;

import javax.naming.NamingException;

import org.oexam.ostudy.db.DBConnection;

public class InsertNewTestSetDetails {
	
	public int testSet_id; 
	public String testSet_name;
	public int noOfTests;
	public String testSetMonth;
	public int testSetYear;
	public boolean isActive; 
	
	public void insert(InsertNewTestSetDetails intsd) throws SQLException, NamingException{
		

		// Temporary code need to change this and add the business logic according to layers.
		
		DBConnection connection = new DBConnection();
		connection.executeQuery("INSERT INTO `OESS_DB`.`TestSets`( `name`, `no_of_tests`, `month`,`year`,`isActive`) VALUES ('"+testSet_name+"',"+noOfTests+",'"+testSetMonth+"',"+testSetYear+","+isActive);
		
		connection.executeQuery("commit");
		
	}
	public int getTestSet_id() {
		return testSet_id;
	}
	public void setTestSet_id(int testSet_id) {
		this.testSet_id = testSet_id;
	}
	public String getTestSet_name() {
		return testSet_name;
	}
	public void setTestSet_name(String testSet_name) {
		this.testSet_name = testSet_name;
	}
	public int getNoOfTests() {
		return noOfTests;
	}
	public void setNoOfTests(int noOfTests) {
		this.noOfTests = noOfTests;
	}
	public String getTestSetMonth() {
		return testSetMonth;
	}
	public void setTestSetMonth(String testSetMonth) {
		this.testSetMonth = testSetMonth;
	}
	public int getTestSetYear() {
		return testSetYear;
	}
	public void setTestSetYear(int testSetYear) {
		this.testSetYear = testSetYear;
	}
	public boolean isActive() {
		return isActive;
	}
	public void setActive(boolean isActive) {
		this.isActive = isActive;
	}
	public void setNoOfTests(String parameter) {
		this.noOfTests = Integer.parseInt(parameter);
		
	}
	public void setTestSetYear(String parameter) {
		this.testSetYear = Integer.parseInt(parameter);
		
	}
	public void setActive(String parameter) {
		if(parameter.equals("true")){
			this.isActive = true;
		} else {
			this.isActive = true;
		}
		
	}


}
